package 字节;


import java.util.Arrays;
import java.util.Scanner;

public class Main_0918_2 {
    public static void main(String[] args) {
        Scanner cin=new Scanner(System.in);
        char[] in=cin.nextLine().toCharArray();
        int n=in.length;
        long[] dp=new long[n];
        long res=1;
        Arrays.fill(dp,1);
        for (int i = 1; i < n; i++) {
            if (in[i]!=in[i-1]){
                dp[i]=dp[i-1]+1;
                res=Math.max(res,dp[i]);
            }
        }
        if (res>=3){
            System.out.println(res);
        }else {
            System.out.println(0);
        }
    }
}
